//
//  ProgressView.swift
//  JIMWeiBo
//
//  Created by 陈恒均 on 2018/2/24.
//  Copyright © 2018年 陈恒均. All rights reserved.
//

import UIKit

class ProgressView: UIView {
    
    var progress : CGFloat = 0{
        didSet{
            setNeedsDisplay()
        }
    }
    

    override func draw(_ rect: CGRect) {
        super.draw(rect)
        let center = CGPoint(x: rect.width * 0.5, y: rect.height * 0.5)
        let radius = rect.width * 0.5 - 3
        let startAngle = CGFloat(Double.pi / 2)
        let endAngle = CGFloat(Double.pi * 2) * progress + startAngle
        
        let path = UIBezierPath(arcCenter: center, radius: radius, startAngle: startAngle, endAngle: endAngle, clockwise: true)
        
        path.addLine(to: center)
        
        UIColor(white: 1.0, alpha: 0.4).setFill()
        
        path.fill()
    }


}
